package demo1.factory;

import demo1.product.Phone;

/**
 * @author ZhouWeiBo
 * @create 2022/6/5
 */
public class MobilePhoneShop {

    /**
     * 需要某一个手机不需要自己制造，只需要去商店买手机即可
     * @return
     */
    public static <T> T buyPhone(Class phoneType){
        Phone phone = null;
        try {
            phone = (Phone)Class.forName(phoneType.getName()).newInstance();
            System.out.println("手机店卖出一部：" + phone.getClass().getSimpleName());
            return (T)phone;
        }catch (Exception e){
            return null;
        }
    }
}
